<template>
  <basic-container>
    <avue-crud
        v-if="tableOption"
        v-bind="bindVal"
        v-on="onEvent"
        v-model:page="page"
        v-model="startForm">

      <template #menu="{type,size,row,index}">
        <el-button v-if="row.procHandlerState!==-10" link :type="type" @click="cancelProcEvent(row)" :size="size">
          取消
        </el-button>
      </template>
    </avue-crud>
    <task-candidate-user-dialog ref="saskCandidateUserDialog"></task-candidate-user-dialog>
    <edit-business-dialog ref="editBusinessDialog" @submit="editBusinessDialogSubmitEvent"></edit-business-dialog>
  </basic-container>
</template>

<script>
import {createStaticMixin} from "@/mixins/startCrud.js"
import TaskCandidateUserDialog from "../components/task/taskCandidateUserDialog.vue";
import startActApi from "@/api/start/activiti/core/startActApi";
import autoRouter from "../autoRouter.js";
import EditBusinessDialog from "@/views/start/activiti/actRunning/editBusinessDialog.vue";
import actBusinessOption from "@/option/start/activiti/actBusinessOption";


const option = {
  option: actBusinessOption,
  api: startActApi,
  list: "pageRunningBusiness"
}
export default {
  components: {EditBusinessDialog, TaskCandidateUserDialog},
  mixins: [createStaticMixin(option)],
  computed: {},
  data() {
    return {}
  },
  created() {
  },
  methods: {
    loadCrudOptionBefore(curdOption) {
      curdOption.addBtn = false;
      curdOption.editBtn = true;
      curdOption.viewBtn = true;
      curdOption.delBtn = false;
      curdOption.permissionBtn = curdOption.permissionBtn || {}
      curdOption.permissionBtn.editBtn = "start:act:task:edit"

    },
    cancelProcEvent(row) {
      let option = {}

      option.beforeClose = (action, instance, done) => {

        if (action !== "confirm") {
          done();
          return
        }
        startActApi.cancelApply(row.id, instance.inputValue).then(res => {
          done();
          this.refreshChange()
        })
      }
      this.$prompt("系统提示", `您确定要取消【${row.procDefName}】此流程申请`, option);
    },
    beforeOpenViewDialog(row, show) {
      let title = "流程详情【" + row.procDefName + "】" + row.procStartUserFinalName
      this.$router.push({path: autoRouter.paths.procDetailPath + "/" + row.id + "/" + title})

    },
    beforeOpenEditDialog(row, show) {
      this.$refs.editBusinessDialog.show(row)
    },
    editBusinessDialogSubmitEvent(done) {
      this.refreshChange();
      if (done) {
        done()
      }
    }
  }
}

</script>
<style scoped>

</style>
